ISubscribe<'TDataEvent>Type
PackageFCQRS
Specification
Kind
Type
Members
4
Examples
0
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Subscribe | this.Subscribe | Subscribes to events matching a specific correlation ID and an additional filter. |
| Subscribe | this.Subscribe | Subscribes to events matching a specific correlation ID. |
| Subscribe | this.Subscribe | Subscribes to events using a filter. |
| Subscribe | this.Subscribe | Subscribes to all events and invokes the specified callback for each event. |
Subscribes to events matching a specific correlation ID and an additional filter.
Parameters
| Name | Type | Description |
|---|---|---|
| cid | CID | The correlation ID to match. |
| filter | 'TDataEvent -> bool | Additional predicate to filter events after CID matching. |
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Subscribes to events matching a specific correlation ID.
Parameters
| Name | Type | Description |
|---|---|---|
| cid | CID | The correlation ID to match. |
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Subscribes to events using a filter. Only events for which the predicate returns true
are processed, and the callback is invoked for each matching event up to a specified count.
Registration is complete when this method returns. The Task succeeds only
after that count is reached; cancellation or disposal before then cancels it.
Parameters
| Name | Type | Description |
|---|---|---|
| filter | 'TDataEvent -> bool |
Predicate function to determine if an event should be processed. To wait for a
correlation ID, use the Subscribe(cid, take) overload instead: it is routed by
correlation ID, and a transactional projection delivers to it only after the events
that caused the notification are committed.
|
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Verification Examples
// Wait for the first notification that matches a predicate. The callback and
// cancellation token are optional.
async {
use subscription = query.Subscribe((fun event -> isPublication event), 1)
do! subscription.Task |> Async.AwaitTask
} |> Async.Start
Subscribes to all events and invokes the specified callback for each event.
Registration is complete when this method returns. Callbacks run in order
on a separate worker; a full subscriber queue drops its oldest notification.
Parameters
| Name | Type | Description |
|---|---|---|
| callback | 'TDataEvent -> unit | Function invoked for each event, e.g. printing or processing the event. |
| cancellationToken | CancellationToken |
Returns
IDisposable
Verification Examples
// Example usage: subscribe to all events and write them to the console.
let subscription =
query.Subscribe((fun event -> printfn "Received event: %A" event))
// Later, to cancel the subscription:
subscription.Dispose()